package com.anyou.mall.pla.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.pla.domain.PlaIdentityType;
import com.anyou.mall.pla.service.IPlaIdentityTypeService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 身份类型Controller
 *
 * @author ylj
 * @date 2022-03-18
 */
@Api(tags = "身份类型")
@RestController
@RequestMapping("/pla/identityType")
public class PlaIdentityTypeController extends BaseController
{
    @Autowired
    private IPlaIdentityTypeService plaIdentityTypeService;

    /**
     * 查询身份类型列表
     */
    @ApiOperation("查询身份类型列表")
    @PreAuthorize("@ss.hasPermi('pla:identityType:list')")
    @GetMapping("/list")
    public TableDataInfo<List<PlaIdentityType>> list(PlaIdentityType plaIdentityType)
    {
        startPage();
        List<PlaIdentityType> list = plaIdentityTypeService.selectPlaIdentityTypeList(plaIdentityType);
        return getDataTable(list);
    }

    /**
     * 导出身份类型列表
     */
    @ApiOperation("导出身份类型列表")
    @PreAuthorize("@ss.hasPermi('pla:identityType:export')")
    @Log(title = "身份类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlaIdentityType plaIdentityType)
    {
        List<PlaIdentityType> list = plaIdentityTypeService.selectPlaIdentityTypeList(plaIdentityType);
        ExcelUtil<PlaIdentityType> util = new ExcelUtil<PlaIdentityType>(PlaIdentityType.class);
        util.exportExcel(response, list, "身份类型数据");
    }

    /**
     * 获取身份类型详细信息
     */
    @ApiOperation("获取身份类型详细信息")
    @PreAuthorize("@ss.hasPermi('pla:identityType:query')")
    @GetMapping(value = "/{identityTypeId}")
    public ApiResult<PlaIdentityType> getInfo(@PathVariable("identityTypeId") Long identityTypeId)
    {
        return ApiResult.success(plaIdentityTypeService.selectPlaIdentityTypeByIdentityTypeId(identityTypeId));
    }

    /**
     * 新增身份类型
     */
    @ApiOperation("新增身份类型")
    @PreAuthorize("@ss.hasPermi('pla:identityType:add')")
    @Log(title = "身份类型", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody PlaIdentityType plaIdentityType)
    {
        return ApiResult.success(plaIdentityTypeService.insertPlaIdentityType(plaIdentityType));
    }

    /**
     * 修改身份类型
     */
    @ApiOperation("修改身份类型")
    @PreAuthorize("@ss.hasPermi('pla:identityType:edit')")
    @Log(title = "身份类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody PlaIdentityType plaIdentityType)
    {
        return ApiResult.success(plaIdentityTypeService.updatePlaIdentityType(plaIdentityType));
    }

    /**
     * 删除身份类型
     */
    @ApiOperation("删除身份类型")
    @PreAuthorize("@ss.hasPermi('pla:identityType:remove')")
    @Log(title = "身份类型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{identityTypeIds}")
    public ApiResult remove(@PathVariable Long[] identityTypeIds)
    {
        return ApiResult.success(plaIdentityTypeService.deletePlaIdentityTypeByIdentityTypeIds(identityTypeIds));
    }

    /**
     * 获取身份类型列表
     */
    @ApiOperation("获取身份类型列表")
    @PreAuthorize("@ss.hasPermi('pla:identityType:allList')")
    @GetMapping("/allList")
    public ApiResult<List<PlaIdentityType>> getAllList() {
        return plaIdentityTypeService.getAllList();
    }
}
